from influxdb_client import InfluxDBClient, Point
from influxdb_client.client.write_api import SYNCHRONOUS


'''
  influx:
    url: http://influxdb-54cb4c629b19222c8291c.rds-sd.mdp.com:8086
    username: limsadmin
    password: UhO}14LnO@q_C[,4g2{u
    database: lims
    #retentionPolicy: one_hour
    retentionPolicy: half_year
'''



client = InfluxDBClient(url="http://localhost:8086", token="YOUR_TOKEN", org="your-org")
write_api = client.write_api(write_options=SYNCHRONOUS)

# 写入数据
point = Point("temperature").tag("location", "room1").field("value", 25.5)
write_api.write(bucket="mybucket", record=point)

# 查询数据
query_api = client.query_api()
result = query_api.query('from(bucket:"mybucket") |> range(start:-1h)')
